package com.zc.microservice.system.core.api.controller;

import com.zc.commons.http.entity.Response;
import com.zc.commons.http.vo.PageResult;
import com.zc.microservice.system.core.api.service.PattenAndRoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 角色管理控制接口
 *
 * @author zcj
 * @version 1.0.0
 * @date 2022/1/21 10:21
 */
@Tag(name = "权限管理")
@RestController
@RequestMapping("/auth")
public class RoleAuthController {

    @Autowired
    private PattenAndRoleService pattenAndRoleService;

    @GetMapping(value = "/test")
    @Operation(summary = "测试测试", tags = {"权限管理"})
    public Response<PageResult<String>> test() {

        pattenAndRoleService.threadLocalTest();
        return Response.ok(PageResult.bulid(1, 2, 3, Arrays.asList("a", "b")));
    }

    @PutMapping(value = "/updateRolePatten/{serverName}")
    @Operation(summary = "更新权限资源", tags = {"权限管理"})
    public Response<Object> updateRolePatten(@Parameter(name = "serverName", description = "服务名称")
                                             @PathVariable String serverName) {
        pattenAndRoleService.updateRolePatten(serverName);
        return Response.ok();
    }


}
